const componentBehavior = require('../../../behaviors/component');
const { COMPONENT_OPTIONS } = require('../../../constants/common');
import { formatPrice } from '../../../common/utils';

Component({
    behaviors: [componentBehavior],
    options: {
        ...COMPONENT_OPTIONS,
    },
    properties: {
        price: {
            type: String,
            optionalTypes: [Number],
            value: '',
        },
        sizeL: {
            type: Number,
            value: 34
        },
        sizeS: {
            type: Number,
            value: 24
        },
        color: {
            type: String,
            value: '#3B434B'
        },
        unit: {
            type: String,
            value: '¥'
        }
    },
    observers: {
        'price': function (val) {
            let [integer, decimal] = `${formatPrice(val, true)}`.split('.')
            this.setData({
                integer,
                decimal: decimal ? decimal : ''
            })
        },
    },
    data: {
        integer: '',
        decimal: ''
    },
})

